<%-- 
    Document   : createCourse
    Created on : Jun 25, 2011, 8:52:53 PM
    Author     : Bob
--%>
<%@include file="include_header.jsp"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="courseData" scope="application" class="edu.gatech.gellinservlet.model.CourseManager" />
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>User Creation - Lab Assistant Pro</title>
    </head>
    <body>
        <%@include file="pro_header.jsp" %>     
        <% //if the user is an admin, load the admin link bar
        if(session.getAttribute("persistUser") instanceof SystemAdmin)
          {
        %>
        <%@include file="admin_list.jsp" %>
        <% } //ends user_redirect else statement, html is included here %>
        <% } //ends verifySession.jsp, all html is included in else statment %>
        <% } //if the user is an instructor, load the instructor link bar
        else if(session.getAttribute("persistUser") instanceof Instructor)
          {
        %>
        <%@include file="instr_list.jsp" %>
        <% } //ends user_redirect else statement, html is included here %>
        <% } //ends verifySession.jsp, all html is included in else statment %>
        <%} //if the user is a student, send him home
        else
       {
                response.sendRedirect("stude_home.jsp");
       }%>
        
        
    <center><h1>Create a New Course!</h1></center>
    <table ALIGN="center" border="1" cellspacing="0" cellpadding="0">
        <form action="" method="post">
            <thead>
                <tr>
                    <th></th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>Course Name:</td>
                    <td><input type="text" name="name" value=""/></td>
                </tr>
                <tr><td><input type="submit" value="Create Course" name="createCourse"/>
                        </input></td>
                </tr>
            </tbody>

        </form>
    </table>
    
    <% //make the course mananger create a course
        Object tempPageVar = session.getAttribute("persistUser");
        String name = request.getParameter("name");
        if (name != null) 
        {
            Course aCourse = courseData.createCourse(name);
            if(tempPageVar instanceof Instructor)
           {
                ((Instructor)tempPageVar).addCourse(aCourse);
           }
        }
        courseData.save("courseData.ser");
            
    %>
    
    </body>
</html>
